package com.nbjtjc.safe.api.danger;

import com.nbjtjc.common.validator.ValidatorUtils;
import com.nbjtjc.common.validator.group.UpdateGroup;
import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.model.danger.DangerReformSheet;
import com.nbjtjc.safe.service.danger.DangerReformSheetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.groups.Default;

/**
 * @auther guqianbin
 * @date 2018/6/28 10:59‘
 * 隐患整改单
 **/
@RestController
@RequestMapping("/danger/reformSheet")
@CrossOrigin("*")
public class DangerReformSheetController {
    @Autowired
    private DangerReformSheetService dangerReformSheetService;
    @GetMapping("/find")
    public Result find(DangerReformSheet dangerReformSheet){
        Result result=new Result();
        result.setData(dangerReformSheetService.find(dangerReformSheet));
        return result;
    }
    @PostMapping("/add")
    public Result add(DangerReformSheet dangerReformSheet){
        Result result=new Result();
        ValidatorUtils.validateEntity(dangerReformSheet);
        result.setData(dangerReformSheetService.add(dangerReformSheet));
        return result;
    }

    @RequestMapping(value = "/update",method = {RequestMethod.POST,RequestMethod.GET})
    public Result update(DangerReformSheet dangerReformSheet){
        Result result=new Result();
        ValidatorUtils.validateEntity(dangerReformSheet,UpdateGroup.class);
        result.setData(dangerReformSheetService.update(dangerReformSheet));
        return result;
    }
}
